package com.hanfengyi.feign.fallback;

import com.hanfengyi.feign.FastDFSFignClient;
import com.hanfengyi.hrm.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * User: Han
 * Date: 2020/2/27
 * Time: 13:36
 * Description:
 */
@Component
public class FastDFSFignFallBack implements FallbackFactory<FastDFSFignClient> {

    @Override
    public FastDFSFignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new FastDFSFignClient() {
            @Override
            public byte[] getTemplateFile(String fileUrl) {
                return null;
            }

            @Override
            public AjaxResult uploadByBytes(byte[] fileBytes, String extName) {
                return AjaxResult.me().setSuccess(false).setMessage("发生了一点小问题:["+throwable.getMessage()+"]");
            }
        };
    }
}